﻿using Barcode_Project.Entity;
using Barcode_Project.Local;
using Barcode_Project.Network;
using DevExpress.Utils.About;
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Barcode_Project.ProBarPrint
{
    public partial class gxPrint : DevExpress.XtraEditors.XtraForm
    {
        Dictionary<string, string> datas;
        public gxPrint(Dictionary<string, string> dic)
        {
            InitializeComponent();

            datas = dic;

            new ComputerTask().LoadPrinter(select_printer);
            new ComputerTask().LoadTemplate(select_template);
            
        }

        private void button_reprint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var plCode = datas["plCode"];
            var gxCode = datas["gxCode"];
            var dt = new RemoteRequest().GetPlanGxInfo(plCode, gxCode);


            
            
            var printerName = ((ItemSelector)select_printer.GetSelectedDataRow()).code;
            var templatePath = ((ItemSelector)select_template.GetSelectedDataRow()).code;//模板路径

            new ComputerTask().StartPrintingTask(dt, printerName, templatePath);
        }

        private void button_exit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void btn_update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var r = XtraMessageBox.Show("即将关闭程序进行升级，是否继续？", "提示", MessageBoxButtons.OKCancel);
            if (r == DialogResult.OK)
            {
                new RemoteRequest().UpdateCmdProgram();
            }
        }
    }
}